<?php
$masuk = $this->session->userdata('masuk');
$this->load->library('cart');
$lib_rupiah = new Format_rupiah();
$lib_img = new images_thumb();

$cart = new CI_Cart();
$keranjang = $cart->contents();

$sub_tot = 0;
$total = 0;
$bny = 0;

foreach ($keranjang as $ct) {
    $bny++;
    $harga = $ct['price'];
    $bnyk = $ct['qty'];
    $diskon = $ct['options']['disc'];
    $sub_tot = ($harga * $bnyk) - ($harga * $bnyk) * $diskon / 100 * $bnyk;
    $total = $total + $sub_tot;
}

$m_setting = new M_setting();
$logo_website = $m_setting->where("id = '6'")->get();
?>



<div id="middleHeader">
    <div class="container">
        <div class="sixteen columns">
            <?php
            if ($logo_website->value != "") {
                echo "<img style='max-height:80px;' src='" . base_url() . "uploads/file/" . $logo_website->value . "'/>";
            } else {
                echo "&nbsp;";
            }
            ?>  <!--end logo-->

            <?php
            echo form_open('main/produk/search_produk/');
            ?> 
            <label>
                <input type="text" name="search" placeholder="Search in Product" value="">
            </label>

            <div class="submit">
                <input type="submit" name="submit">
            </div>
            </form><!--end form-->

        </div><!--end sixteen-->
    </div><!--end container-->
</div><!--end middleHeader-->


<div class="container">
    <div class="sixteen columns">
        <div id="mainNav" class="clearfix">
            <nav>
                <ul>
                    <li><?php echo anchor("main/produk", "Produk", "class='home'") ?></li>
                    <li><?php echo anchor("main/keranjang", "Keranjang ", "class='cart'") ?></li>
                    <li>
                        <?php
                        if ($masuk)
                            echo anchor("main/member", "Menu Member", "class='member'");
                        else
                            echo anchor("main/login_signup", "Menu Member", "class='member'");
                        ?>
                    </li>
                    <li><?php echo anchor("main/informasi", "Informasi Pemesanan", "class='informasi'") ?></li>
                    <li><?php echo anchor("main/kontak", "Kontak", "class='kontak'") ?></li>
                    <li>
                        <?php
                        if ($masuk)
                            echo anchor("main/login_signup/logout", "Sign Out", "class='kontak'");
                        else
                            echo anchor("main/login_signup", "Login / Sign Up", "class='kontak'");
                        ?>
                    </li>


                </ul>
            </nav><!--end nav-->

            <div id="cart">
                <a class="cart_dropdown" href="javascript:void(0);"><img src="<?php echo base_url() ?>assets/client/images/icons/cart_icon.png" alt=""> <?php echo $bny; ?> items<span>:  <?php echo $lib_rupiah->rupiah($total); ?> </span></a>
                <div class="cart_content">
                    <b class="cart_content_arrow"></b>
                    <ul>
                        <?php
                        foreach ($keranjang as $dta) {
                            $harga = $dta['price'];
                            $bnyk = $dta['qty'];
                            $diskon = $dta['options']['disc'];
                            $sub = ($harga * $bnyk) - ($harga * $bnyk) * $diskon / 100 * $bnyk;
                            $gambar = base_url() . "uploads/" . $dta['options']['id_produk'] . "/" . $lib_img->image($dta['options']['image']);
                            ?>

                            <li>
                                <div class="cart_product_name">
                                    <img src="<?php echo $gambar; ?>" alt="product image" width="50">
                                    <span>
                                        <strong><?php echo anchor("main/produk/produk_det/" . $dta['options']['id_produk'], $dta['name']); ?></strong><br>
                                        Color: <?php echo $dta['options']['Color'] ?><br>
                                        Size: <?php echo $dta['options']['Size'] ?>
                                    </span>
                                </div>
                                <div class="cart_product_price">
                                    <span>
                                        <?php echo $lib_rupiah->rupiah($sub) ?><br>
                                        <!--                                    <a class="remove_item" href="#">Remove</a>-->
                                    </span>
                                </div>
                                <div class="clear"></div>
                            </li>
                            <?php
                        }
                        ?>
                    </ul><!--end ul-->



                </div><!--end cart_content-->
            </div><!--end cart-->

        </div><!--end main-->
    </div><!--end sixteen-->
</div><!--end container-->

